#include<bits/stdc++.h>
using namespace std;
int a[10000],n;
int c[10000];
int vvv;
void dfs(int c[],int t)
{
    if (t==n)
    {
        int ans=0;
        for (int i=0;i<n;i++)
        {
            for (int j=i-1;j>=0;j--)
            {
                if (c[i]==c[j]&&a[i]==a[j])
                {
                    ans+=a[i];
                    break;
                }
            }
        }
        vvv=max(vvv,ans);
        return ;
    }
    c[t]=1;
    dfs(c,t+1);
    c[t]=2;
    dfs(c,t+1);
    return ;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int t;
    cin>>t;
    while (t--)
    {
        memset(a,0,sizeof(a));
        cin>>n;
        for (int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        vvv=-1;
        dfs(c,0);
        cout<<vvv<<'\n';
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
